package com.hmy.equipment.controller;

import com.hmy.equipment.domain.HmyEquipment;
import com.hmy.equipment.mapper.HmyEquipmentMapper;
import com.hmy.equipment.service.HmyEquipmentService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author ljy
 * @Date 2024/2/22 11:16
 * @description: 栏舍环境收集
 * @Title: HmyEquipmentController
 * @Package com.hmy.equipment.controller
 */
@RestController
@RequestMapping("/equipment")
public class HmyEquipmentController extends BaseController {
    @Autowired
    private HmyEquipmentService hmyEquipmentService;
    @Resource
    private HmyEquipmentMapper hmyEquipmentMapper;

    /**
     * @param hmyEquipment
     * @return com.ruoyi.common.core.web.domain.AjaxResult
     * @description 获取所有数据
     * @author ljy
     * @date 2024/2/22 11:19:14
     */
    @GetMapping("/find")
    public TableDataInfo findAll(HmyEquipment hmyEquipment) {
        return getDataTable(hmyEquipmentService.findList(hmyEquipment));
    }

    /**
     * @param
     * @return com.ruoyi.common.core.web.domain.AjaxResult
     * @description 获取所有表格编码
     * @author ljy
     * @date 2024/2/22 15:51:29
     */
    @GetMapping("/findCode")
    public AjaxResult findCode() {
        return AjaxResult.success(hmyEquipmentMapper.findPhouseCode());
    }

    @PostMapping("/save")
    public AjaxResult save(@RequestBody HmyEquipment hmyEquipment) {
        return AjaxResult.success(hmyEquipmentMapper.save(hmyEquipment));
    }
}
